<%@ include file="/common/taglibs.jsp"%>
<%@taglib uri='/WEB-INF/cewolf.tld' prefix='cewolf' %>
<head>
    <title><fmt:message key="supplierList.title"/></title>

    <meta name="heading" content="<fmt:message key='reportMaterialGral.heading'/>"/>
    <meta name="menu" content="RolePurchaseReport"/>
    <script type="text/javascript" src="<c:url value='/scripts/calendar/calendar.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/calendar/lang/calendar-es.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/calendar/calendar-setup.js'/>"></script>
    <script type="text/javascript">
        function choiceTypeReport(){
            document.reportMaterialGralChoiceForm.submit();
        }
    </script>
</head>
<div id="help">
    <h2>
        <a href="<c:url value='helpReportMaterialGral.html?decorate=false'/>"
           title="Help report material gral"
           onclick="Modalbox.show(this.href, {title: this.title, width: 600}); return false;">
               <fmt:message key="help"/>
        </a>
    </h2>
</div>
<table>
    <tr>
        <td>
        <table border="0">
            <tbody>
            <tr>
                <td>
                    <fieldset>
                        <legend><fmt:message key="reportMaterialGral.typeReport"/></legend>
                        <s:form action="reportMaterialGralChoice" name="reportMaterialGralChoiceForm" >
                            <s:radio list="typeReport"  name="typeReportChoice" value="typeReportChoice"
                                     onclick="choiceTypeReport();"/>
                        </s:form>
                    </fieldset>
                </td>
            </tr>
        </table>
        <s:form id="reportMatGralGenerateForm" action="reportMaterialPeriodSelect" method="get" validate="true">
            <table>
                <tr>
                    <td>
                        <c:if test="${typeReportChoice == '1'}">
                            <script type="text/javascript">

                                window.onload = function() {
                                    Calendar.setup({
                                        inputField: "dateStartID",
                                        ifFormat: "%d/%m/%Y",
                                        button: "dateStartID"
                                    });

                                    Calendar.setup({
                                        inputField: "dateEndID",
                                        ifFormat: "%d/%m/%Y",
                                        button: "dateEndID"
                                    });
                                }

                            </script>
                            <s:hidden name="typeReportChoice" value="1"/>
                            <fieldset>
                                <legend><fmt:message key="reportMaterialGral.perMonth"/></legend>
                                <table>
                                    <tr><td>
                                        <s:textfield key="reportMaterialGral.perMonth.dateStart" id="dateStartID" size="9" 
                                                     required="true" name="dateStart"/>

                                        </td>
                                        <td>
                                            <s:textfield key="reportMaterialGral.perMonth.dateEnd" name="dateEnd" id="dateEndID"
                                                         size="9" required="true" />
                                        </td>
                                    </tr>
                                </table>
                            </fieldset>
                        </c:if>
                        <c:if test="${typeReportChoice == '2'}">
                            <s:hidden name="typeReportChoice" value="2"/>
                            <fieldset>
                                <legend><fmt:message key="reportMaterialGral.perYear"/></legend>
                                <table>
                                    <tr><td>
                                            <s:select list="numYearList" name="yearStart"
                                                      listKey="label" listValue="label"
                                                      headerKey="-1" headerValue="-- Seleccione --" key="reportMaterialGral.perYear.yearStart"/>
                                        </td>
                                        <td>
                                            <s:select list="numYearList" name="yearEnd"
                                                      listKey="label" listValue="label"
                                                      headerKey="-1" headerValue="-- Seleccione --" key="reportMaterialGral.perYear.yearEnd" />
                                        </td>
                                    </tr>
                                </table>
                                <br/>
                                <br/>
                            </fieldset>
                        </c:if>
                    </td>
                </tr>
                <tr>
                    <td>
                        <br/>
                        <s:hidden name="decorate" value="false"/>
                        <s:submit cssClass="button" key="button.generate" theme="ajax" targets="imageMaterialReport"/>
                        <br/>
                        <br/>
                    </td>
                </tr>
                </tbody>
            </table>

        </td>
        <td>
            <fieldset>
                <legend><fmt:message key="reportMaterialGral.materials"/></legend>

                <s:optiontransferselect list="materialListLeft"
                                        leftTitle="Mats. Stock"
                                        doubleList="materialListRight"
                                        rightTitle="Gen."

                                        doubleName="selectMaterials" />

            </fieldset>
        </td>
        </tr>

    </table>
</s:form>

<s:url id="imageGenerateUrl" action="ajaxMaterialReport" >
    <s:param name="decorate" value="false" />
</s:url>

<s:div id="imageMaterialReport" theme="ajax" href="%{imageGenerateUrl}" loadingText="%{getText('ajax.loading')}..."/>


